#pragma once

#ifdef _DEBUG
    #define _CRTDBG_MAP_ALLOC
    #include <crtdbg.h>
#endif

#include <afx.h>
#include <afxtempl.h>
#include <afxrich.h>

#include <windows.h>

#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <sys/utime.h>
#include <time.h>

#include <winsock2.h>
#include <winioctl.h>
#include <mmsystem.h>
#include <winspool.h>
#include <setupapi.h>
#include <devguid.h>
#include <dbt.h>
#include <dbghelp.h>
#include <vfw.h>
#include <WindowsX.h>
#include <WinInet.h>

#include <ntddscsi.h>
#include <ntddcdrm.h>
#include <ntddkbd.h>
#include <ntddpar.h>

#include <dxerr.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <ddraw.h>
#include <dsound.h>
#include <dinput.h>

#include <Functiondiscoverykeys_devpkey.h>
#include <Audioclient.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>

#ifdef _DEBUG
    #define new DEBUG_NEW
#endif

typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned int uae_ptr;
typedef long long long64;
typedef unsigned long long ulong64;

//  This one remove compiler warning. Someone just forgot to provide this type in
//  windows headers. It's perfectly legal under C++, but when compiling under CLR
//  its produce some scary warnings.
struct _TREEITEM { };
struct _IMAGELIST { };
struct pcap { };

/* Every Amiga hardware clock cycle takes this many "virtual" cycles.  This
   used to be hardcoded as 1, but using higher values allows us to time some
   stuff more precisely.
   512 is the official value from now on - it can't change, unless we want
   another config option "finegrain2_m68k_speed".

   We define this value here rather than in events.h so that gencpu.c sees
   it.  */
#define CYCLE_UNIT 512

/* This one is used by cfgfile.c.  We could reduce the CYCLE_UNIT back to 1,
   I'm not 100% sure this code is bug free yet.  */
#define OFFICIAL_CYCLE_UNIT 512

/*
 * You can specify numbers from 0 to 5 here. It is possible that higher
 * numbers will make the CPU emulation slightly faster, but if the setting
 * is too high, you will run out of memory while compiling.
 * Best to leave this as it is.
 */
#define CPU_EMU_SIZE 0

#define xmalloc(T, N) static_cast<T*>(malloc(sizeof(T) * (N)))
#define xcalloc(T, N) static_cast<T*>(calloc(sizeof(T), N))
#define xrealloc(T, TP, N) static_cast<T*>(realloc(TP, sizeof(T) * (N)))

#define DBLEQU(f, i) (abs((f) - (i)) < 0.000001)

//  wpcap support
#define HAVE_REMOTE

using namespace std;

#pragma warning (disable: 4018) // L3: Comparing a signed and unsigned number required the compiler to convert the signed value to unsigned
#pragma warning (disable: 4100) // L4: 'identifier' : unreferenced formal parameter
#pragma warning (disable: 4244) // L4: 'conversion' conversion from 'type1' to 'type2', possible loss of data
#pragma warning (disable: 4245) // L4: 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
#pragma warning (disable: 4389) // L4: An operation involved signed and unsigned variables. This could result in a loss of data.
#pragma warning (disable: 4706) // L4: assignment within conditional expression
#pragma warning (disable: 4146) // L2: unary minus operator applied to unsigned type, result still unsigned
#pragma warning (disable: 4305) // L1: The identifier is converted to a smaller type, resulting in loss of information.
#pragma warning (disable: 4309) // L2: The type conversion causes a constant to exceed the space allocated for it. You may need to use a larger type for the constant.
#pragma warning (disable: 4800) // L3: 'type' : forcing value to bool 'true' or 'false' (performance warning)
#pragma warning (disable: 4345) // L2: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
#pragma warning (disable: 4611) // L4: interaction between 'function' and C++ object destruction is non-portable

#ifdef WIN64
    #pragma warning (disable: 4267) //@ 'var' : conversion from 'size_t' to 'type', possible loss of data
#endif

#ifdef _MANAGED
    #pragma warning (disable: 4793) //@ L1, L3: 'function' : function is compiled as native code: 'reason'
    #pragma warning (disable: 4996) //@ L3: 'function': was declared deprecated
    #pragma warning (disable: 4564) //@ L3: 'function': was declared deprecated
#endif

#include "Logging.h"
#include "Helpers.h"
#include "Logger.h"
#include "unicode.h"
#include "Configuration.h"
#include "..\resources\resource.h"
#include "AmigaConfiguration.h"
#include "FloppiesSounds.h"
#include "Shaders.h"